<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var arr = [3, 15, 8, 28, 102, 22];

    arr.sort((x, y) => {
        console.log(x + '-' + y + '=' + (x - y));
        return x - y;
    });
    console.log(arr);

    arr.sort((y, x) => x - y)//[3, 8, 15, 22, 28, 102]
    console.log(arr);//[102, 28, 22, 15, 8, 3]

</script>

</html>